Skip to content

feat(block): make furnaces smelt, burn fuel and show progress - #156

Open
xRookieFight wants to merge 2 commits into
devfrom
feat/furnace
Open

feat(block): make furnaces smelt, burn fuel and show progress#156
xRookieFight wants to merge 2 commits into
devfrom
feat/furnace

Conversation

@xRookieFight

Copy link
Copy Markdown
Contributor

Description

Furnaces were a block and a recipe that produced a block nobody could use: no screen, no smelting, no fuel, no cook time.

  • A smelting table and a fuel table in item: ores and raw metals into ingots, food into cooked food, sand into glass, and the usual fuels from a stick to a lava bucket.
  • Right clicking a furnace, blast furnace or smoker opens its own screen with the three slots the client expects. Contents go through the same per-position container storage the chest already uses, so they persist and drop on break like anything else.
  • A furnace burns a piece of fuel only when there is something to cook and somewhere to put it, cooks one item per burn cycle, and swaps between its lit and unlit block while keeping the way it faces. Blast furnaces and smokers cook in half the time.
  • Progress is sent to whoever has the furnace open, so the flame and the arrow move.
  • Ticking arrives through a new worldrt.BlockEntityTicker, the same shape as the existing PlayerTicker: the world runtime owns the clock, the session decides what a tick means. Only furnaces with something to do are visited.

Related issue

Part of #125

Two gaps worth naming:

ContainerSetDataPacket has no alias in protocol.current, so the progress packet is reached through the version it was last changed in - the same workaround as MobArmorEquipmentPacket in #149. Both would be better as aliases upstream.

Checklist

  • v -check . is clean
  • v test server/item/smelting_test.v, server/block/furnace_test.v, server/world/db, and the session inventory/items/blocks/runtime/registry/place/break tests are green
  • Follows the conventions in AGENTS.md (OOP, pub/capitalized exports, no import cycles, minimal comments)
  • Cross-session gameplay state is only mutated on its owning world's actor thread (via world_call/wr.submit/WorldTx), never through a global Hub actor
  • No unrelated changes bundled in

Comment thread server/session/furnace.v

// furnace_can_cook reports whether the input smelts into something the output
// slot still has room for.
fn furnace_can_cook(mut tx worldrt.WorldTx, x int, y int, z int) bool {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

furnace_can_cook() doesn't receive/use the furnace variant so smoker/blast furnace appear to accept every entry in the shared smelting table.

Comment thread server/session/furnace.v
}

// light_furnace consumes one piece of fuel, if there is any.
fn light_furnace(mut tx worldrt.WorldTx, x int, y int, z int, state db.FurnaceState) db.FurnaceState {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consuming lava_bucket currently just removes the stack. Shouldn't this leave an empty bucket in the fuel slot?

Comment thread server/item/smelting.v

// fuel_burn_ticks is how long an item keeps a furnace lit, or none when it
// does not burn.
pub fn fuel_burn_ticks(name string) ?int {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not every slab is burnable (stone for example)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants